package com.twu.biblioteca;

import java.util.Arrays;

public class LibraryMenuState implements State {

    public static LibraryMenuState instance = new LibraryMenuState();
    String[] options = {"1. Choose A Book", "2.Back To Main Menu"};
    Library library = new Library();

    private LibraryMenuState(){}

    @Override
    public String[] getOptions() {
        System.out.println(library.getBookList());
        return options;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public State act(String input) {

        int choice = Integer.parseInt(input);
        if (choice == 1)
            return BookMenuState.instance;
        else
            return MainMenuState.instance;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isValidInput(String input) {
        try {
            Integer choice = Integer.parseInt(input);
            return ((choice > 0) && (options.length > choice - 1));
        }
        catch (Exception e) {
            return false;
        }
    }
}
